This is the holder GUI widget for images. It's main purpose is to work around some of the bugs in the Ruby Gtk implementation of Gtk::Image. Would be nice to inherit from Gtk::Image but the implementation is buggy and throws exceptions when the constructor is not given a Gdk::Pixbuf.
Initialize an empty container with the current epoch set to 0.
# File lib/gui_graph.rb, line 14 def initialize super @epoch = 0 end
Displays the image specified by the file at 'graph_file'. The current image is only updated if the epoch passed here is different from the last time it was called.
# File lib/gui_graph.rb, line 22 def show_graph(graph_file, epoch) return if @epoch == epoch @epoch = epoch begin graph_image = Gdk::Pixbuf.new(graph_file) rescue IOError => e puts e puts "Cannot load image!" exit end # Gtk::Image seems very buggy. Have to be careful with it if not @image.nil? remove(@image) @image.destroy end @image = Gtk::Image.new(graph_image) add(@image) show_all end